{include file="public/_meta" /}
<body>
<style>
    .required_b{
        color: red;
    }
</style>
<div class="wrapper">

    {include file="public/_header" /}

    <!-- Sidebar -->
    {include file="public/_menu" /}
    <!-- End Sidebar -->

    <div class="main-panel">

        <div class="content">
            <div class="page-inner">

                <!-- 面包屑 -->
                {include file="public/_page_header" /}

                <div class="row">
                    <div class="col-md-12">
                        <div class="card">
                            <div class="card-header">
                                <div class="d-flex align-items-center">
                                    <h4 class="card-title">MD5人群包(查询后导出)</h4>
                                </div>

                                <form class="row">
<!--                                    <div class="col-md-6 col-lg-2">-->
<!--                                        <div class="form-group">-->
<!--                                            <input type="text" class="form-control" name="ac_name" value="{$ac_name}" placeholder="账户名称">-->
<!--                                        </div>-->
<!--                                    </div>-->

<!--                                    <div class="col-md-6 col-lg-2">-->
<!--                                        <div class="form-group">-->
<!--                                            <input type="text" class="form-control" name="adv_id" value="{$adv_id}" placeholder="账户ID">-->
<!--                                        </div>-->
<!--                                    </div>-->
<!--                                    <div class="col-md-6 col-lg-2">-->
<!--                                        <div class="form-group">-->
<!--                                            <input type="text" class="form-control" name="clue_name" value="{$clue_name}" placeholder="线索ID">-->
<!--                                        </div>-->
<!--                                    </div>-->
<!--                                    <div class="col-md-6 col-lg-2">-->
<!--                                        <div class="form-group">-->
<!--                                            <input type="text" class="form-control" name="clue_name" value="{$clue_name}" placeholder="线索名称">-->
<!--                                        </div>-->
<!--                                    </div>-->

<!--                                    <div class="col-md-6 col-lg-2">-->
<!--                                        <div class="form-group">-->
<!--                                            <input type="text" class="form-control" name="phone" value="{$phone}" placeholder="电话">-->
<!--                                        </div>-->
<!--                                    </div>-->

<!--                                    <div class="col-md-6 col-lg-2">-->
<!--                                        <div class="form-group">-->
<!--                                            <input type="text" class="form-control" name="mer_name" value="{$mer_name}" placeholder="商户名称">-->
<!--                                        </div>-->
<!--                                    </div>-->

<!--                                    <div class="col-md-6 col-lg-2">-->
<!--                                        <div class="form-group">-->
<!--                                            <input type="text" class="form-control" name="cityname" value="{$cityname}" placeholder="请输入城市">-->
<!--                                        </div>-->
<!--                                    </div>-->

<!--                                    <div class="col-md-6 col-lg-2">-->
<!--                                        <div class="form-group">-->
<!--                                            <select class="form-control" name="status">-->
<!--                                                <option value="99"  {if condition="$status eq 99"}selected{/if}>全部状态</option>-->
<!--                                                <option value="1"  {if condition="$status eq 1"}selected{/if}>已推送</option>-->
<!--                                                <option value="0"  {if condition="$status eq 0"}selected{/if}>未推送</option>-->
<!--                                            </select>-->
<!--                                        </div>-->
<!--                                    </div>-->

                                    <div class="col-md-6 col-lg-2">
                                        <div class="form-group">

                                            <select class="form-control input-full" name="pro_id" id="pro_id">
                                                <option value="">全部产品</option>
                                                {volist name="products" id="vo"}
                                                <option value="{$key}">{$vo}</option>
                                                {/volist}
                                            </select>
                                        </div>
                                    </div>

<!--                                    <div class="col-md-6 col-lg-2">-->
<!--                                        <div class="form-group">-->
<!--                                            <select class="form-control" name="source">-->
<!--                                                <option value="0">全部线索来源</option>-->
<!--                                                {volist name="sources" id="vo"}-->
<!--                                                <option value="{$vo.source}" {if condition="$vo.source eq $source"}selected{/if}>{$vo.source}</option>-->
<!--                                                {/volist}-->
<!--                                            </select>-->
<!--                                        </div>-->
<!--                                    </div>-->

                                    <div class="col-md-6 col-lg-2">
                                        <div class="form-group">
                                            <input type="text" class="form-control" name="times" id="times" value="{$times}" placeholder="创建时间" autocomplete="off">
                                        </div>
                                    </div>

                                    <div class="col-md-6 col-lg-2">
                                        <div class="form-group">
                                            <span class="layui-laypage-count btn" >共 {$total} 条</span>
                                        </div>
                                    </div>

                                    <div class="col-md-6 col-lg-2">
                                        <div class="form-group">
                                            <button type="submit" class="btn btn-primary">查询</button>
                                            <button type="button" class="btn btn-primary" onclick="dataexport()">导出</button>
                                            <a href="{:url('Operate/userMd5')}" class="btn btn-info" style="color: white;position: absolute;left: 200px;">重置</a>
                                        </div>
                                    </div>

                                </form>

                            </div>


                            <div class="card-body">
                                <!-- Modal -->
                                <div class="modal fade" id="addRowModal" tabindex="-1" role="dialog" aria-hidden="true">
                                    <div class="modal-dialog" role="document">
                                        <div class="modal-content">
                                            <div class="modal-header no-bd">
                                                <h5 class="modal-title">
                                                    <span class="fw-mediumbold">添加</span>

                                                </h5>
                                                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                                    <span aria-hidden="true">&times;</span>
                                                </button>
                                            </div>
                                            <div class="modal-body">
                                                <form id="form-modal">
                                                    <div class="row">

                                                        <div class="form-group form-inline col-md-12">
                                                            <label for="clue_name" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">线索名称 <b class="required_b">*</b> </font></label>
                                                            <div class="col-md-8 p-0">
                                                                <input type="text" class="form-control input-full" id="clue_name" name="clue_name" placeholder="线索名称">
                                                            </div>
                                                        </div>

                                                        <div class="form-group form-inline col-md-12">
                                                            <label for="phone" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">电话<b class="required_b">*</b></font></label>
                                                            <div class="col-md-8 p-0">
                                                                <input type="text" class="form-control input-full" id="phone" name="phone" placeholder="电话">
                                                            </div>
                                                        </div>

                                                        <div class="form-group form-inline col-md-12">
                                                            <label for="apply_limit" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">申请金额<b class="required_b">*</b></font></label>
                                                            <div class="col-md-8 p-0">
                                                                <input type="text" class="form-control input-full" id="apply_limit" name="apply_limit" placeholder="申请金额">
                                                            </div>
                                                        </div>

                                                        <div class="form-check form-inline col-md-12">
                                                            <div class="col-md-8 p-0">
                                                                <div class="form-check">
                                                                    <label class="col-md-3 col-form-label"><font style="vertical-align: inherit;">性别</font></label>
                                                                    <label class="form-radio-label" style="margin-left: 20px;">
                                                                        <input class="form-radio-input" type="radio" name="gender" value="1" checked="">
                                                                        <span class="form-radio-sign">男</span>
                                                                    </label>
                                                                    <label class="form-radio-label ml-3">
                                                                        <input class="form-radio-input" type="radio" name="gender" value="2">
                                                                        <span class="form-radio-sign">女</span>
                                                                    </label>
                                                                    <label class="form-radio-label ml-3">
                                                                        <input class="form-radio-input" type="radio" name="gender" value="0">
                                                                        <span class="form-radio-sign">未知</span>
                                                                    </label>
                                                                </div>
                                                            </div>
                                                        </div>

                                                        <div class="form-group form-inline col-md-12">
                                                            <label for="age" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">年龄</font></label>
                                                            <div class="col-md-8 p-0">
                                                                <input type="text" class="form-control input-full" id="age" name="age" placeholder="年龄">
                                                            </div>
                                                        </div>

                                                        <div class="form-group form-inline col-md-12">
                                                            <label for="province" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">省份/直辖市</font></label>
                                                            <div class="col-md-8 p-0">
                                                                <select class="form-control input-full" name="province" id="province" onchange="loadRegion('province',2,'city')">
                                                                    <option value="0">省份/直辖市</option>
                                                                    {volist name="province" id="vo"}
                                                                    <option value="{$vo.id}">{$vo.name}</option>
                                                                    {/volist}
                                                                </select>
                                                            </div>
                                                        </div>

                                                        <div class="form-group form-inline col-md-12">
                                                            <label for="city" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">市/县</font></label>
                                                            <div class="col-md-8 p-0">
                                                                <select class="form-control input-full" name="city" id="city" onchange="loadRegion('city',3,'town')">
                                                                    <option value="0">市/县</option>
                                                                </select>
                                                            </div>
                                                        </div>

                                                        <div class="form-group form-inline col-md-12">
                                                            <label for="source" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">来源</font></label>
                                                            <div class="col-md-8 p-0">
                                                                <input type="text" class="form-control input-full" id="source" name="source" placeholder="来源">
                                                            </div>
                                                        </div>
                                                        <div class="form-group form-inline col-md-12">
                                                            <label for="wx_id" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">微信号</font></label>
                                                            <div class="col-md-8 p-0">
                                                                <input type="text" class="form-control input-full" id="wx_id" name="wx_id" placeholder="微信号">
                                                            </div>
                                                        </div>
                                                        <div class="form-group form-inline col-md-12">
                                                            <label for="qq" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">QQ号</font></label>
                                                            <div class="col-md-8 p-0">
                                                                <input type="text" class="form-control input-full" id="qq" name="qq" placeholder="QQ号">
                                                            </div>
                                                        </div>
                                                        <div class="form-group form-inline col-md-12">
                                                            <label for="email" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">邮箱</font></label>
                                                            <div class="col-md-8 p-0">
                                                                <input type="text" class="form-control input-full" id="email" name="email" placeholder="邮箱">
                                                            </div>
                                                        </div>
                                                        <div class="form-group form-inline col-md-12">
                                                            <label for="remark" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">备注</font></label>
                                                            <div class="col-md-8 p-0">
                                                                <textarea id="remark" name="remark" class="form-control input-full" style="height: 300px!important"></textarea>
                                                            </div>
                                                        </div>

                                                    </div>
                                                    <div class="modal-footer no-bd">
                                                        <input type="hidden" id="id" name="id" value="">
                                                        <button type="submit" id="addRowButton" class="btn btn-primary">保存</button>
                                                        <button type="button" class="btn btn-danger" data-dismiss="modal">关闭</button>
                                                    </div>
                                                </form>
                                            </div>

                                        </div>
                                    </div>
                                </div>

                                <div class="modal fade" id="addRowModal2" tabindex="-1" role="dialog" aria-hidden="true">
                                    <div class="modal-dialog" role="document">
                                        <div class="modal-content">
                                            <div class="modal-header no-bd">
                                                <h5 class="modal-title">
                                                    <span class="fw-mediumbold">推送</span>

                                                </h5>
                                                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                                    <span aria-hidden="true">&times;</span>
                                                </button>
                                            </div>
                                            <div class="modal-body">
                                                <form id="form-modal2">
                                                    <div class="row">

                                                        <div class="form-group form-inline col-md-12">
                                                            <label for="province" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">推送商户</font></label>
                                                            <div class="col-md-8 p-0">
                                                                <select class="form-control input-full" name="merchant" id="merchant" onchange="loadRule('merchant','mrule')">
                                                                    <option value="0">--请选择--</option>
                                                                </select>
                                                            </div>
                                                        </div>

                                                        <div class="form-group form-inline col-md-12">
                                                            <label for="province" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">分发规则</font></label>
                                                            <div class="col-md-8 p-0">
                                                                <select class="form-control input-full" name="mrule" id="mrule">
                                                                    <option value="0">--请选择--</option>
                                                                </select>
                                                            </div>
                                                        </div>

                                                        <div class="form-group form-inline col-md-12">
                                                            <label for="province" class="col-md-3 col-form-label"><font style="vertical-align: inherit;color: red">显示城市</font></label>
                                                            <div class="col-md-8 p-0">
                                                                <input type="text" class="form-control input-full" id="show_city" name="show_city"  placeholder="商户端显示城市">

                                                            </div>
                                                        </div>

                                                        <div class="form-group form-inline col-md-12">
                                                            <label for="clue_name" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">线索名称  </font></label>
                                                            <div class="col-md-8 p-0">
                                                                <input type="text" class="form-control input-full" id="clue_name2"  placeholder="线索名称" disabled>
                                                            </div>
                                                        </div>

                                                        <div class="form-group form-inline col-md-12">
                                                            <label for="phone" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">电话</font></label>
                                                            <div class="col-md-8 p-0">
                                                                <input type="text" class="form-control input-full" id="phone2"  placeholder="电话" disabled>
                                                            </div>
                                                        </div>


                                                        <div class="form-group form-inline col-md-12">
                                                            <label for="province" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">城市</font></label>
                                                            <div class="col-md-8 p-0">
                                                                <div id="city2"></div>

                                                            </div>
                                                        </div>

                                                        <div class="form-group form-inline col-md-12">
                                                            <label for="remark" class="col-md-3 col-form-label"><font style="vertical-align: inherit;">备注</font></label>
                                                            <div class="col-md-8 p-0">
                                                                <textarea id="remark2"  class="form-control input-full" style="height: 300px!important" disabled></textarea>
                                                            </div>
                                                        </div>

                                                    </div>
                                                    <div class="modal-footer no-bd">
                                                        <input type="hidden" id="id2" name="id" value="">
                                                        <button type="submit" id="addRowButton2" class="btn btn-primary">保存</button>
                                                        <button type="button" class="btn btn-danger" data-dismiss="modal">关闭</button>
                                                    </div>
                                                </form>
                                            </div>

                                        </div>
                                    </div>
                                </div>


                                <div class="table-responsive">
                                    <!--<table id="add-row" class="display table table-striped table-hover" >
                                        <thead>
                                        <tr>
                                            <th>ID</th>
                                            <th>线索电话</th>
                                            <th>MD5电话</th>

                                            <th>创建时间</th>
                                        </tr>
                                        </thead>

                                        <tbody>

                                        {volist name="infos" id="vo"}
                                        <tr>
                                            <td>{$vo.id}</td>
                                            <td>{$vo.phone}</td>
                                            <td>{$vo.md5p}</td>


                                            <td>{$vo.create_time}

                                            </td>
                                        </tr>
                                        {/volist}

                                        </tbody>
                                    </table>-->

                                    <!-- 分页 (调取通用方法)-->
                                     <div class="layui-box layui-laypage layui-laypage-molv">{:pagination($infos)}</div>

                                </div>
                            </div>
                        </div>
                    </div>
                </div>


            </div>
        </div>

        {include file="public/_footer" /}


    </div>



</div>

{include file="public/_js" /}

</body>

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript">
    var SCOPE = {
        'status_url':"{:url('clue/status')}",
        'status_urla':"{:url('clue/statusAll')}",
        'delete_url':"{:url('clue/delete')}",
        'delete_url2':"{:url('clue/delete2')}",
        'item_url':"{:url('clue/edit')}",
        'item_url2':"{:url('clue/edit2')}",
        'item_url3':"{:url('clue/edit3')}",
        'add_url':"{:url('clue/save')}",
        'clue_url':"{:url('clue/clue_url')}",
        'city_url':"{:url('clue/getRegion')}",
        'push_rule':"{:url('clue/getMerchantPush')}",
        'push_url':"{:url('clue/findPush')}",
    };


    function loadRule(sel,selName){
        $("#"+selName+" option").each(function(){
            $(this).remove();
        });
        $("<option value=0>请选择</option>").appendTo($("#"+selName));
        if($("#"+sel).val()==0){
            return;
        }
        $.post(SCOPE.push_rule,{pid:$("#"+sel).val()},
            function(data){
                if(data.code == 1001){
                    $.each(data.data,function(idx,item){
                        $("<option value="+item.id+">【"+item.dcity+"】【"+item.dcharge_type+"】(单价"+item.price+")</option>").appendTo($("#"+selName));
                    });
                }else{
                    $("<option value='0'>请选择</option>").appendTo($("#"+selName));
                }
            }
        );
    }

    function loadRegion(sel,type_id,selName){
        $("#"+selName+" option").each(function(){
            $(this).remove();
        });
        $("<option value=0>请选择</option>").appendTo($("#"+selName));
        if($("#"+sel).val()==0){
            return;
        }
        $.post(SCOPE.city_url,{pid:$("#"+sel).val(),type:type_id},
            function(data){
                if(data.code == 1001){
                    $.each(data.data,function(idx,item){
                        $("<option value="+item.id+">"+item.name+"</option>").appendTo($("#"+selName));
                    });
                }else{
                    $("<option value='0'>请选择</option>").appendTo($("#"+selName));
                }
            }
        );
    }

    $(function(){
        var commitStatus = false;
        /*表单验证*/
        $("#form-modal").validate({
            rules:{
                clue_name:{
                    required:true,
                    maxlength:30
                },
                phone:{
                    required:true,
                    number:true,
                    minlength:11,
                    maxlength:11
                },
                age:{
                    number:true
                },
                email:{
                    email:true,
                    maxlength:100
                },
                wx_id:{
                    maxlength:30
                },
                qq:{
                    maxlength:30
                },
                remark:{
                    maxlength:300
                }

            },
            onkeyup:false,
            focusCleanup:true,
            success:"valid",
            submitHandler:function(form){
                var url = SCOPE.add_url;
                if(commitStatus==true){
                    return false;
                }
                var province = $("#province").val();
                var city = $("#city").val();
                if(province != 0 && city == 0){
                    layer.msg('请选择市/县',{icon:2,time:2000});
                    return false;
                }
                /*表单提交*/
                $(form).ajaxSubmit({
                    type: 'post',
                    url: url,
                    success: function(data){
                        if(data.code == 1001){
                            commitStatus = true;
                            layer.msg(data.msg, {
                                icon: 1,
                                time: 2000
                            }, function(){
                                parent.location.reload();
                            });
                        }else{
                            layer.msg(data.msg,{icon:2,time:2000});
                        }
                    },
                    error: function(XmlHttpRequest, textStatus, errorThrown){
                        layer.msg(errorThrown,{icon:2,time:2000});
                    }
                });

            }
        });

    });

    //指定推送
    $(function(){
        var commitStatus = false;
        /*表单验证*/
        $("#form-modal2").validate({

            onkeyup:false,
            focusCleanup:true,
            success:"valid",
            submitHandler:function(form){
                var url = SCOPE.push_url;
                if(commitStatus==true){
                    return false;
                }

                var loading = layer.load(0, {
                    shade: true,
                    time: 10*1000
                });
                /*表单提交*/
                $(form).ajaxSubmit({
                    type: 'post',
                    url: url,
                    success: function(data){
                        if(data.code == 1001){
                            commitStatus = true;
                            layer.msg(data.msg, {
                                icon: 1,
                                time: 2000
                            }, function(){
                                layer.close(loading);
                                parent.location.reload();
                            });
                        }else{
                            layer.msg(data.msg,{icon:2,time:2000});
                            layer.close(loading);
                        }
                    },
                    error: function(XmlHttpRequest, textStatus, errorThrown){
                        layer.msg(errorThrown,{icon:2,time:2000});
                    }
                });

            }
        });

    });

    function add_item(id) {
        $("input[name='id']").val(id);
        document.getElementById('form-modal').reset();
        $("#city").children().remove();
        $("<option value='0'>请选择</option>").appendTo($("#city"));
        $(".fw-mediumbold").text('添加');
    }

    function edit_item(id) {
        $("#city").children().remove();
        $("<option value='0'>请选择</option>").appendTo($("#city"));
        $.ajax({
            type: 'GET',
            url: SCOPE.item_url,
            dataType: 'json',
            data: {id:id},
            success: function(res){
                if(res.code == 1001){
                    $(".fw-mediumbold").text('编辑');
                    $("#id").val(res.data.id);
                    $("#clue_name").val(res.data.clue_name);
                    $("#phone").val(res.data.phone);
                    $("#age").val(res.data.age);
                    $("#source").val(res.data.source);
                    $("#email").val(res.data.email);
                    $("#wx_id").val(res.data.wx_id);
                    $("#qq").val(res.data.qq);
                    $("#remark").val(res.data.remark);
                    $(":radio[name='gender'][value='"+res.data.gender+"']").prop("checked","checked");
                    $("#province").val(res.data.prov);
                    $("#apply_limit").val(res.data.apply_limit);
                    if(res.data.city != ''){
                        $("#city").children().remove();
                        $("<option value='"+res.data.city+"'>"+res.data.city_name+"</option>").appendTo($("#city"));
                    }
                }else{
                    layer.msg(res.msg,{icon:2,time:2000});
                }

            },
            error:function(res) {
                layer.msg('网络错误,稍后再试...',{icon:2,time:2000});
            }
        });
    }

    function edit_item2(id,city) {
        $("#mrule").children().remove();
        $("<option value='0'>请选择</option>").appendTo($("#mrule"));
        $.ajax({
            type: 'GET',
            url: SCOPE.item_url2,
            dataType: 'json',
            data: {id:id},
            success: function(res){
                if(res.code == 1001){
                    $(".fw-mediumbold").text('推送');
                    $("#id2").val(res.data.id);
                    $("#clue_name2").val(res.data.clue_name);
                    $("#phone2").val(res.data.phone);

                    $("#remark2").val(res.data.remark);
                    $("#city2").text(city);

                    $("#merchant").children().remove();


                    $.each(res.data.merchant,function(k,v) {
                        $("<option value='"+v.id+"'>【"+v.mer_name+"】【账号"+v.username+"】(联系电话"+v.phone+")</option>").appendTo($("#merchant"));
                    });

                }else{
                    layer.msg(res.msg,{icon:2,time:2000});
                }

            },
            error:function(res) {
                layer.msg('网络错误,稍后再试...',{icon:2,time:2000});
            }
        });
    }

    function edit_item3() {
        $("#mrule").children().remove();
        $("<option value='0'>请选择</option>").appendTo($("#mrule"));
        $.ajax({
            type: 'GET',
            url: SCOPE.item_url3,
            dataType: 'json',
            success: function(res){
                if(res.code == 1001){

                    var chk_value =[];
                    $('input[name="idcheckbox"]:checked').each(function(){ //遍历，将所有选中的值放到数组中
                        chk_value.push($(this).val());
                    });

                    $(".fw-mediumbold").text('推送');
                    $("#id2").val(chk_value);
                    $("#clue_name2").val('批量多条线索');
                    $("#phone2").val('批量多条线索');

                    $("#remark2").val('批量多条线索');
                    $("#city2").text('批量多条线索');

                    $("#merchant").children().remove();


                    $.each(res.data.merchant,function(k,v) {
                        $("<option value='"+v.id+"'>【"+v.mer_name+"】【账号"+v.username+"】(联系电话"+v.phone+")</option>").appendTo($("#merchant"));
                    });

                }else{
                    layer.msg(res.msg,{icon:2,time:2000});
                }

            },
            error:function(res) {
                layer.msg('网络错误,稍后再试...',{icon:2,time:2000});
            }
        });
    }



    /*删除*/
    function admin_del(obj,id){
        layer.confirm('确认要直接删除,不退款吗？',function(index){
            $.ajax({
                type: 'POST',
                url: SCOPE.delete_url,
                dataType: 'json',
                data: {id:id},
                success: function(data){
                    if(data.code == 1001){
                        $(obj).parents("tr").remove();
                        layer.msg('删除线索成功!',{icon:1,time:2000});
                    }else{
                        layer.msg(data.msg,{icon:2,time:2000});
                    }

                },
                error:function(data) {
                    layer.msg('网络错误,稍后再试...',{icon:2,time:2000});
                }
            });
        });
    }

    /*删除*/
    function admin_del2(obj,id){
        layer.confirm('确认要删除并且退款吗？',function(index){
            $.ajax({
                type: 'POST',
                url: SCOPE.delete_url2,
                dataType: 'json',
                data: {id:id},
                success: function(data){
                    if(data.code == 1001){
                        $(obj).parents("tr").remove();
                        layer.msg('删除线索成功!',{icon:1,time:2000});
                    }else{
                        layer.msg(data.msg,{icon:2,time:2000});
                    }

                },
                error:function(data) {
                    layer.msg('网络错误,稍后再试...',{icon:2,time:2000});
                }
            });
        });
    }


    /*机构-停用*/
    function admin_stop(obj,id){
        layer.confirm('确认要禁止推送吗？',function(index){
            //此处请求后台程序，下方是成功后的前台处理……
            var url = SCOPE.status_url;
            $.post(url,{status:2,id:id},function(data){
                if(data.code == 1001){
                    layer.msg('已禁止推送!',{icon: 1,time:1000},function(){
                        window.location.reload();
                    });
                }else{
                    layer.msg(data.msg,{icon: 2,time:1000});
                }

            });


        });
    }

    /*机构-启用*/
    function admin_start(obj,id){
        layer.confirm('确认要推送线索吗？',function(index){
            //此处请求后台程序，下方是成功后的前台处理……

            var url = SCOPE.status_url;
            $.post(url,{status:1,id:id},function(data){
                if(data.code == 1001){

                    layer.msg('已推送!',{icon: 1,time:1000},function(){
                        window.location.reload();
                    });
                }else{
                    layer.msg(data.msg,{icon: 2,time:1000});
                }
            });
        });
    }

    /*机构-启用*/
    function admin_all(){
        layer.confirm('确认要批量推送线索吗？',function(index){
            //此处请求后台程序，下方是成功后的前台处理……

            var loding=showLoad();

            var url = SCOPE.status_urla;
            var chk_value =[];
            $('input[name="idcheckbox"]:checked').each(function(){ //遍历，将所有选中的值放到数组中
                chk_value.push($(this).val());
            });



            $.post(url,{status:1,id:chk_value},function(data){
                if(data.code == 1001){

                    layer.msg(data.msg,{icon: 1,time:3000},function(){
                        window.location.reload();
                    });
                }else{
                    layer.msg(data.msg,{icon: 2,time:1000});
                }
                closeLoad(loding);
            });

        });
    }

    /*查看重复*/
    function selectclue(obj,phone){
        location.href='{:url("clue/index")}?clue_name=&phone='+phone+'&status=99&pro_id=&times='
    }

    laydate.render({
        elem: '#times'
        ,type: 'datetime'
        ,range: true
    });

    // $('#pro_id').find('option[value="{$pro_id}"]').attr('selected',true);
    $('#pro_id').val('{$pro_id}');

    function showLoad() {

        return layer.msg('拼命执行中...', {icon: 16,shade: [0.5, '#f5f5f5'],scrollbar: false,offset: 'auto', time:100000});

    }

    function closeLoad(index) {
        layer.close(index);

    }


    function dataexport(){

        var times=$("#times").val();
        var pro_id=$("#pro_id").val();
        location.href="{:url('operate/userMd5Export')}"+'?times='+times+'&pro_id='+pro_id;
    }

</script>
</html>




























